﻿function ULS_SP() {
    if (ULS_SP.caller) {
        ULS_SP.caller.ULSTeamName = "Windows SharePoint Services 4";
        ULS_SP.caller.ULSFileName = "/_layouts/INC/MS.InformationManagement/JS/PageComponent.js";
    }
}

Type.registerNamespace('RibbonCustomization');

// RibbonApp Page Component
RibbonCustomization.PageComponent = function () {
    ULS_SP();
    RibbonCustomization.PageComponent.initializeBase(this);
}
RibbonCustomization.PageComponent.initialize = function () {
    ULS_SP();
    ExecuteOrDelayUntilScriptLoaded(
        Function.createDelegate(
            null,
            RibbonCustomization.PageComponent.initializePageComponent),
        'SP.Ribbon.js');
}
RibbonCustomization.PageComponent.initializePageComponent = function () {
    ULS_SP();
    var ribbonPageManager = SP.Ribbon.PageManager.get_instance();
    if (null !== ribbonPageManager) {
        ribbonPageManager.addPageComponent(RibbonCustomization.PageComponent.instance);
        ribbonPageManager
            .get_focusManager()
            .requestFocusForComponent(RibbonCustomization.PageComponent.instance);
    }
}
RibbonCustomization.PageComponent.refreshRibbonStatus = function () {
    SP.Ribbon.PageManager
        .get_instance()
        .get_commandDispatcher()
        .executeCommand(Commands.CommandIds.ApplicationStateChanged, null);
}
RibbonCustomization.PageComponent.prototype = {
    getFocusedCommands: function () {
        ULS_SP();
        return [];
    },
    getGlobalCommands: function () {
        ULS_SP();
        return getGlobalCommands();
    },
    isFocusable: function () {
        ULS_SP();
        return true;
    },
    receiveFocus: function () {
        ULS_SP();
        return true;
    },
    yieldFocus: function () {
        ULS_SP();
        return true;
    },
    canHandleCommand: function (commandId) {
        ULS_SP();
        return commandEnabled(commandId);
    },
    handleCommand: function (commandId, properties, sequence) {
        ULS_SP();
        return handleCommand(commandId, properties, sequence);
    }
}

// Register classes
RibbonCustomization.PageComponent.registerClass(
    'RibbonCustomization.PageComponent',
    CUI.Page.PageComponent);
RibbonCustomization.PageComponent.instance = new RibbonCustomization.PageComponent();

// Notify waiting jobs
NotifyScriptLoadedAndExecuteWaitingJobs(
    "/_layouts/INC/MS.InformationManagement/JS/PageComponent.js");
